/*
 *  InitAgentNetwork.cpp
 *  Milovo04alfa00
 *
 *  Created by Luca on 08/11/06.
 *  Copyright 2006 __MyCompanyName__. All rights reserved.
 *
 */

#include "MilovoTables.h"

bool CreateRawMaterials(MilinitParams &, Artifacts *, MilovoEnvironment &);
void CreateInitRecipe(MilinitParams &, SystemParams &, Agents *, Mil_Int , Recipes *, Artifacts *, MilovoRandom &, MilovoEnvironment &);
void LoadAgentStyleParam(string , Mil_Int, Agents *, int);
void PrintAgentsNetwork(Agents *, Recipes *, Artifacts *);

void InitAgentsNetwork(string tmpWorkingDir, MilinitParams &tmpInitParam, SystemParams &tmpMilovoParam, Agents *tmpTabAgents, Recipes *tmpTabRecipes, 
							 Artifacts *tmpTabArtifacts, MilovoRandom &tmpMiloRand, MilovoEnvironment &tmpMiloEnv)
{
	if(tmpInitParam.GetSeedRandomValue() > 0)
		tmpMiloRand.seed(tmpInitParam.GetSeedRandomValue());
	
	CreateRawMaterials(tmpInitParam, tmpTabArtifacts, tmpMiloEnv);
	for(Mil_Int CurrentIDAgentToCreate = 1; CurrentIDAgentToCreate <= tmpInitParam.GetNumAgents(); CurrentIDAgentToCreate++)
	{
		// insert in TabAgents the new agent
		tmpTabAgents->insert(make_pair(CurrentIDAgentToCreate, Agent(CurrentIDAgentToCreate, tmpInitParam.GetStartActivityAgents(), tmpMiloEnv.GetCurrentStep())));
		if((tmpMiloEnv.GetDebugLevel() > 0) && (tmpTabAgents->find(CurrentIDAgentToCreate) == tmpTabAgents->end()))
			exit(EXIT_FAILURE);
		// create style of this new agent
		LoadAgentStyleParam(tmpWorkingDir, CurrentIDAgentToCreate, tmpTabAgents, tmpMiloEnv.GetDebugLevel());
		// create recipes of this new agent
		Mil_Int HowManyRecipesThisAgent = tmpMiloRand.GetIntRandom(tmpInitParam.GetNumMinRecipesPerAgent(), tmpInitParam.GetNumMaxRecipesPerAgent());
		for(Mil_Int CurrentIDRecipeToCreate = 0; CurrentIDRecipeToCreate < HowManyRecipesThisAgent; CurrentIDRecipeToCreate++)
			CreateInitRecipe(tmpInitParam, tmpMilovoParam, tmpTabAgents, CurrentIDAgentToCreate, tmpTabRecipes, tmpTabArtifacts, tmpMiloRand, tmpMiloEnv);

		GenerateRelationshipThisAgent(CurrentIDAgentToCreate, tmpTabAgents, tmpTabRecipes, tmpTabArtifacts, tmpMiloEnv.GetCurrentStep(), 
												tmpMiloEnv.GetDebugLevel());
	}
	
	if(tmpMiloEnv.GetDebugLevel() >= 2)
		PrintAgentsNetwork(tmpTabAgents, tmpTabRecipes, tmpTabArtifacts);
}

bool CreateRawMaterials(MilinitParams &tmp_InitParam, Artifacts *tmp_TabArtifacts, MilovoEnvironment &tmp_MiloEnv)
{
	bool FlagRawSuccess = true;
	
	Mil_Int tmpKeyToInsert = 1;
	for(vector<Mil_Int>::iterator VectRawMaterialsIter = tmp_InitParam.VectRawMaterials.begin(); VectRawMaterialsIter != tmp_InitParam.VectRawMaterials.end(); VectRawMaterialsIter++)
	{
		Mil_Int tmpNameThisRawMaterial = *VectRawMaterialsIter;
		tmp_TabArtifacts->insert(make_pair(tmpKeyToInsert, Artifact(tmpKeyToInsert, tmpNameThisRawMaterial, 0, 0, -1, 1000000, 1000000, 0, 0)));
		if((tmp_MiloEnv.GetDebugLevel() >= 0) && (tmp_TabArtifacts->find(tmpKeyToInsert) == tmp_TabArtifacts->end()))
		{
			cout << "CreateRawMaterials function cannot insert a new artifact in TabArtifacts" << endl;
			exit(EXIT_FAILURE);
		}
		tmpKeyToInsert++;
	}
	
	if(tmp_MiloEnv.GetDebugLevel() >= 0)
	{
		cout << "-- Raw Materials (begin) --" << endl;
		for(Artifacts::iterator TabArtifactsIter = tmp_TabArtifacts->begin(); TabArtifactsIter != tmp_TabArtifacts->end(); ++TabArtifactsIter)
			cout << "ArtID: " << TabArtifactsIter->second.GetID() << "\tName: " << TabArtifactsIter->second.GetName() << endl;
		cout << "-- Raw Materials (end) --" << endl;
	}
	
	return(FlagRawSuccess);
}

void CreateInitRecipe(MilinitParams &tmp_InitParam, SystemParams &tmp_MilovoParam, Agents *tmp_TabAgents, Mil_Int tmpCurrentIDAgentToCreate, 
							 Recipes *tmp_TabRecipes, Artifacts *tmp_TabArtifacts, MilovoRandom &tmp_MiloRand, MilovoEnvironment &tmp_MiloEnv)
{
	Agents::iterator tmp_TabAgentsIter = tmp_TabAgents->find(tmpCurrentIDAgentToCreate);
	if((tmp_MiloEnv.GetDebugLevel() >= 0) && (tmp_TabAgentsIter == tmp_TabAgents->end()))
	{
		cout << "Error sending parameters in CreateInitRecipe function: Agent doesn't exist" << endl;
		exit(EXIT_FAILURE);
	}
	// create a new recipe mean firstly extract artifacts available for
	// current agent, secondly build the new recipe around parameters.
	// For artifacts available we intend every artifacts knowed by current
	// agent excluded those artifacts produced by itself.
	// An output recipe cannot be equal to a raw material
	vector<Mil_Int> VectIDArtifactsAvailable = ExtractVectIDArtifactsAvailableThisAgent(tmpCurrentIDAgentToCreate, tmp_TabArtifacts, tmp_MiloEnv.GetDebugLevel());
	// follow a cicle for selecting a set of artifacts and operators which output is ok
	bool FlagFoundValidRecipe = false;
	while(FlagFoundValidRecipe == false)
	{
		if(tmp_MiloEnv.GetDebugLevel() >= 1)
			cout << "Try to build a new initialization recipe" << endl;
		list<Mil_Int> tmpListIDInput;
		list<Mil_Int> tmpListOperators;
		// select number of artifacts constituents recipe to create
		Mil_Int tmpHowManyArtifactsThisRecipe = tmp_MiloRand.GetIntRandom(tmp_InitParam.GetNumMinArtifactsPerRecipe(), tmp_InitParam.GetNumMaxArtifactsPerRecipe());
		// insert artifacts in a list manage by recipe
		for(Mil_Int tmpHowManyArtifactsThisRecipeIndex = 0; tmpHowManyArtifactsThisRecipeIndex < tmpHowManyArtifactsThisRecipe; tmpHowManyArtifactsThisRecipeIndex++)
			tmpListIDInput.push_back(VectIDArtifactsAvailable[tmp_MiloRand.GetIntRandom(0, (VectIDArtifactsAvailable.size() - 1))]);
		// insert operators in a list manage by recipe
		Mil_Int tmpHowManyOperatorsThisRecipe = tmpHowManyArtifactsThisRecipe - 1;
		for(Mil_Int tmpHowManyOperatorsThisRecipeIndex = 0; tmpHowManyOperatorsThisRecipeIndex < tmpHowManyOperatorsThisRecipe; tmpHowManyOperatorsThisRecipeIndex++)
			tmpListOperators.push_back(tmp_InitParam.VectOperators[tmp_MiloRand.GetIntRandom(0, tmp_InitParam.VectOperators.size() - 1)]);
		// calculate output of this new recipe
		Mil_Int tmpOutputThisRecipe = CalcOutputThisRecipe(tmpListIDInput, tmpListOperators, tmp_TabArtifacts, tmp_MiloEnv.GetDebugLevel());
		// prepare a vector within the artifacts name that output racipe cannot assume
		vector<Mil_Int> VectToCompareForOutput;
		vector<Mil_Int> VectIDAgentsToAnalize;
		VectIDAgentsToAnalize.push_back(tmpCurrentIDAgentToCreate);
		CheckOutputThisAgentToCompare(VectToCompareForOutput, tmp_InitParam, VectIDAgentsToAnalize, tmp_TabAgents, tmp_TabRecipes, 
												tmp_TabArtifacts, tmp_MiloEnv.GetDebugLevel());
		// Only for Initialization save the type of recipe validation
		Mil_Int SaveValidateRecipeOutputThisAgent = tmp_TabAgentsIter->second.Style.GetValidateRecipeOutput();
		tmp_TabAgentsIter->second.Style.SetValidateRecipeOutput(tmp_InitParam.GetValidateRecipeOutputInitNet());
		// check if output is into boundaries and its name is different to raw materials
		tmpOutputThisRecipe = ValidateThisOutputRecipe(tmp_MilovoParam.GetMinNameArtifactAllowed(), tmp_MilovoParam.GetMaxNameArtifactAllowed(), 
																	  VectToCompareForOutput, tmpOutputThisRecipe, 0, tmp_TabAgents, tmpCurrentIDAgentToCreate, 
																	  tmp_InitParam, tmp_MiloEnv.GetDebugLevel());
		
		tmp_TabAgentsIter->second.Style.SetValidateRecipeOutput(SaveValidateRecipeOutputThisAgent);
		if(tmpOutputThisRecipe != 0)
		{
			FlagFoundValidRecipe = true;
			InsertNewRecipe(tmp_InitParam, tmp_MilovoParam, tmp_MiloRand, tmp_TabAgents, tmpCurrentIDAgentToCreate, tmp_TabRecipes, tmp_TabArtifacts, tmpListIDInput, 
								 tmpListOperators, tmpOutputThisRecipe, tmpHowManyArtifactsThisRecipe, 0, tmp_MiloEnv.GetDebugLevel());
			if(tmp_MiloEnv.GetDebugLevel() >= 1)
				cout << "Initialization of new recipe... ok" << endl << "----------------------------------------" << endl;			
		}
	}
}

void LoadAgentStyleParam(string strPath, Mil_Int tmpIDAgent, Agents *tmp_TabAgents, int tmp_DebugLevel)
{
	string StrFileLoadAgentsStyle = strPath + "MilovoAgentsStyle.csv";
	ifstream fid_LoadAgentsStyle;
	
	fid_LoadAgentsStyle.open(StrFileLoadAgentsStyle.c_str(), ios::in);
	string tmpSingleLine;
	while(getline(fid_LoadAgentsStyle, tmpSingleLine))
	{
		Mil_Int tmpTabPos = tmpSingleLine.find("\t");
		string tmpStrIDAgent(tmpSingleLine, 0, tmpTabPos);
		if(atol(tmpStrIDAgent.c_str()) == tmpIDAgent)
		{
			Agents::iterator tmp_TabAgentsIter = tmp_TabAgents->find(tmpIDAgent);
			if((tmp_DebugLevel >= 0) && (tmp_TabAgentsIter == tmp_TabAgents->end()))
			{
				cout << "Error in LoadAgentStyleParam function: cannot find tmpIDAgent passed by parameter" << endl;
				exit(EXIT_FAILURE);
			}
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrUseImitation(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetProbImitation(atof(StrUseImitation.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrUseJump(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetProbJump(atof(StrUseJump.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrStartJumpRange(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetStartJumpRange(atof(StrStartJumpRange.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrEndJumpRange(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetEndJumpRange(atof(StrEndJumpRange.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrSelectGoalInAgentOutput(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetSelectGoalInAgentOutput(atol(StrSelectGoalInAgentOutput.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrProbGoalFromRequest(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetProbGoalFromRequest(atof(StrProbGoalFromRequest.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrProbDevelopNewGoal(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetProbDevelopNewGoal(atof(StrProbDevelopNewGoal.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrHowManyNewFriends(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetHowManyNewFriends(atol(StrHowManyNewFriends.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrKnowledgeDecay(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetKnowledgeDecay(atol(StrKnowledgeDecay.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrIncludeZeroAgentInNewFriends(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetIncludeZeroAgentInNewFriends(atol(StrIncludeZeroAgentInNewFriends.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrInnovationStrategy(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetInnovationStrategy(atol(StrInnovationStrategy.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrSelectPartnerMode(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetSelectPartnerMode(atol(StrSelectPartnerMode.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrValidateRecipeOutput(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetValidateRecipeOutput(atol(StrValidateRecipeOutput.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrNProduceFloor(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetNProduceFloor(atol(StrNProduceFloor.c_str()));			
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrNProduceCeil(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetNProduceCeil(atol(StrNProduceCeil.c_str()));			
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrMaxRecipesAllowed(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetMaxRecipesAllowed(atol(StrMaxRecipesAllowed.c_str()));			
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrUseSuppliersChange(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetUseSuppliersChange(atof(StrUseSuppliersChange.c_str()));			
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrAlfaTransactions(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetAlfaTransactions(atof(StrAlfaTransactions.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrBetaProjects(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetBetaProjects(atof(StrBetaProjects.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrLambdaTransactions(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetLambdaTransactions(atof(StrLambdaTransactions.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrLambdaProjects(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetLambdaProjects(atof(StrLambdaProjects.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrValueSuccessedProjects(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetValueSuccessedProjects(atof(StrValueSuccessedProjects.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrValueFailedProjects(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetValueFailedProjects(atof(StrValueFailedProjects.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrProjectsDeadLevel(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetProjectsDeadLevel(atof(StrProjectsDeadLevel.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrScaffProb(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetScaffProb(atof(StrScaffProb.c_str()));

			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrAcceptScaffMinLevel(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetAcceptScaffMinLevel(atol(StrAcceptScaffMinLevel.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrUseDeepSearchGoal(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetUseDeepSearchGoal(atol(StrUseDeepSearchGoal.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrChangeSupplierMethod(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetChangeSupplierMethod(atol(StrChangeSupplierMethod.c_str()));
			
			tmpSingleLine.assign(tmpSingleLine, tmpTabPos + 1, tmpSingleLine.size());
			tmpTabPos = tmpSingleLine.find("\t");
			string StrProduceRecipeMethod(tmpSingleLine, 0, tmpTabPos);
			tmp_TabAgentsIter->second.Style.SetProduceRecipeMethod(atol(StrProduceRecipeMethod.c_str()));
		}
	}
	fid_LoadAgentsStyle.close();
}

void PrintAgentsNetwork(Agents *tmp_TabAgents, Recipes *tmp_TabRecipes, Artifacts *tmp_TabArtifacts)
{
	cout << "**************** Print Agents Network [Begin] ****************" << endl;
	for(Agents::iterator tmp_TabAgentsIter = tmp_TabAgents->begin(); tmp_TabAgentsIter != tmp_TabAgents->end(); tmp_TabAgentsIter++)
	{
		cout << "AgentID:" << tmp_TabAgentsIter->second.GetID() << endl;
		cout << "\tProbInno: " << tmp_TabAgentsIter->second.Style.GetProbImitation() << "\tProbJump: " << tmp_TabAgentsIter->second.Style.GetProbJump() 
			<< "\tStartJumpRange: " << tmp_TabAgentsIter->second.Style.GetStartJumpRange() << "\tEndJumpRange: " << tmp_TabAgentsIter->second.Style.GetEndJumpRange() << endl;
		for(list<Mil_Int>::iterator LinkRecipesIter = tmp_TabAgentsIter->second.LinkRecipes.begin(); LinkRecipesIter != tmp_TabAgentsIter->second.LinkRecipes.end(); LinkRecipesIter++)
		{
			Recipes::iterator tmp_TabRecipesIter = tmp_TabRecipes->find(*LinkRecipesIter);
			cout << "\tRecipeID: " << *LinkRecipesIter << endl << "\t"; 
			
			list<Mil_Int>::iterator LinksOperatorsIter = tmp_TabRecipesIter->second.LinksOperators.begin();
			for(list<Mil_Int>::iterator LinksIDArtifactsIter = tmp_TabRecipesIter->second.LinksIDArtifacts.begin(); LinksIDArtifactsIter != tmp_TabRecipesIter->second.LinksIDArtifacts.end(); LinksIDArtifactsIter++)
			{
				Artifacts::iterator tmp_TabArtifactsIter = tmp_TabArtifacts->find(*LinksIDArtifactsIter);
				cout << "\tArtID: " << *LinksIDArtifactsIter << "(" << tmp_TabArtifactsIter->second.GetName() << ")";
				if(LinksOperatorsIter != tmp_TabRecipesIter->second.LinksOperators.end())
				{
					cout << "\tOp: " << *LinksOperatorsIter;
					LinksOperatorsIter++;
				}
			}
			Artifacts::iterator tmp_TabArtifactsIter = tmp_TabArtifacts->find(tmp_TabRecipesIter->second.GetIDArtifactOutput());
			cout << " = ArtID: " << tmp_TabArtifactsIter->second.GetID() << "(" << tmp_TabArtifactsIter->second.GetName() << ")" << endl;
		}
	}
	cout << "**************** Print Agents Network [End] ****************" << endl;
}

